package com.vvv.controller;

import com.vvv.common.BaseResponse;
import com.vvv.model.dto.IdRequest;
import com.vvv.model.entity.CourseInfo;
import com.vvv.service.UserCourseinfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author vvv
 * @date 2023-12-08 15 28
 * discription
 */
@RestController
@RequestMapping("/user-course")
public class UserCourseController {

    @Resource
    private UserCourseinfoService userCourseinfoService;

    @PostMapping("/grabbing")
    public BaseResponse<Boolean> grabbing(@RequestBody IdRequest idRequest, HttpServletRequest request) {
        userCourseinfoService.grabbingCourse(idRequest, request);
        return BaseResponse.success(true);
    }

    @PostMapping("/dropping")
    public BaseResponse<Boolean> dropping(@RequestBody IdRequest idRequest, HttpServletRequest request) {
        userCourseinfoService.droppingCourse(idRequest, request);
        return BaseResponse.success(true);
    }

    @GetMapping("/query/selectedCourse")
    public BaseResponse<CourseInfo> querySelectedCourse(HttpServletRequest request) {
        CourseInfo courseInfo = userCourseinfoService.querySelectedCourse(request);
        return BaseResponse.success(courseInfo);
    }
}
